class AddEvent < ActiveRecord::Migration
  def self.up
    create_table :events do |t|
      t.column :title, :string
      t.column :category, :integer
      t.column :start_at, :datetime
      t.column :end_at, :datetime
      t.column :location, :string
      t.column :content, :text
      t.column :content_html, :text
      t.column :school_id, :integer
      
      t.column :submitor_id, :integer
      t.column :is_closed, :boolean, :default => false
      t.column :is_hidden, :boolean, :default => false
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
    end
    
    create_table :participations do |t|
      t.column :user_id, :integer
      t.column :event_id, :integer
      t.column :rank, :integer
      t.column :created_at, :datetime
    end
    
    create_table :event_pics do |t|
      t.column :parent_id, :integer
      t.column :content_type, :string
      t.column :filename, :string
      t.column :thumbnail, :string
      t.column :size, :integer
      t.column :width, :integer
      t.column :height, :integer
      
      t.column :event_id, :integer
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
    end
    
    create_table :event_comments do |t|
      t.column :event_id, :integer
      t.column :user_id, :integer
      t.column :title, :string
      t.column :content, :text
      t.column :content_html, :text
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
    end
  end

  def self.down
    drop_table :events
    drop_table :participations
    drop_table :event_pics
    drop_table :event_comments
  end
end
